<?php
class UserActionController extends  ActionController{
	
	public function run(){
		$size = sizeof($this->params);
		if($size<1 || empty($this->params['action'])){
			self::index();
		} else {
			switch($this->params['action']){
				case 'add':
					self::add();
					break;
				case 'auth':
					self::auth();
					break;
				case 'logout':
					self::logout();
					break;
				default:
					self::index();
			}
		}
		$this->view->setRenderTemplete('index.tmp');
	}
	public function index(){
		$model = new UserModel();
		//TODO: MODEL INDEX
		$this->view->modelTitle = $model->getTitle();
	}
	public function add(){
		
            if($this->params != NULL){
                
                //TODO: проверить параметры
                $model = new UserModel();
				$model->setParams($this->params);
				$model->addUser();
				//TODO: проверить в осуществимости действий
				
                
                
            }else{
                header('Location: http://localhost/social/social/');
				exit;
            }
	}
	public function auth(){
		$model = new UserModel();
		$model->setParams($this->params);
		$model->setView($this->view);
		$model->auth();
	}
	public function logout(){
		session_destroy();
	}
}
?>